home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 1
/
Nebula One.iso
/
Utilities
/
Converters
/
Convert_PICT
/
Source
/
CommentedPSCode
/
Patterns
< prev
next >
Wrap
Text File
|
1995-06-12
|
3KB
|
149 lines
%BEGIN Patterns
% Copyright (C) 1993 David John Burrowes
% Distributed under terms of GNU General Public License.
% See COPYING.text in Convert PICT's CommentedPSCode for a copy
%%%%%%%%%%%%%
% Notes:
% qdpat is an 8 byte hex string, like <AA55AA55AA55AA55>
% clut-info is a hex string of RGB byte triples for color lookup
% pict2pat is either of:
% qdpat [r g b] 2
% qdpat num clut-info bitdepth left top width height
% destwidth destheight packedflag bitmap-string 1
% See the common routine usePattern for how much of this is used
%%%%%%%%%%%%%
%%%%%%%%%%%%%
% Name: GetPatGrey
% Syntax: qdpat GetPatGrey num
% About: Given a hex string representing 8 bytes of data, assume it is a
% quickdraw B&W pattern. Calculate what percentage of the pixels
% are black, and return the % grey
%%%%%%%%%%%%%
/GetPatGrey
{
/QDpattern exch def
/darkness 0 def
%
% for each byte of pattern, convert to value between 0 and 1 and sum
% This is not completely accurate, but works well enough (it counts #'s, not bits)
%
0 1 7
{
/patByte exch def
/darkness
QDpattern patByte get
255 div darkness add
def
}
for
%
% Compute the average shade and push
%
darkness 8 div
}
def
%%%%%%%%%%%%%
% Name: FillQDPatDict
% Syntax: qdpat 0 FillQDPatDict -
% pict2pat FillQDPatDict -
% About: Store pattern info we are passed. This assumes an appropriate
% dictionary has been opened and is on the stack.
%%%%%%%%%%%%%
/FillQDPatDict
{
begin
/QDPatType exch def
QDPatType 0 eq
{
/QDPatData exch def
/QDPatGrey QDPatData GetPatGrey def
}
{
QDPatType 2 eq
{
/QDColorValue exch def
pop % B&W pattern not needed. color will suffice.
}
{
/QDPatBitmap exch def
/QDisPacked exch def
/QDDestHeight exch def
/QDDestWidth exch def
/Height exch def
/Width exch def
/QDTop exch def
/QDLeft exch def
/BitsPerComponent exch def
/QDColorTable exch def
/QDNumColors exch def
/QDPatData exch def
/QDPatGrey QDPatData GetPatGrey def
}
ifelse
}
ifelse
end
}
def
%%%%%%%%%%%%%
% Name: bkPat [0002]
% Syntax: qdpat 0 bkPat -
% About: Stores the pattern info in the backPattern dict.
%%%%%%%%%%%%%
/bkPat
{backPattern FillQDPatDict}
def
%%%%%%%%%%%%%
% Name: pnPat [0009]
% Syntax: qdpat 0 pnPat -
% About: Stores the pattern info in the penPattern dict.
%%%%%%%%%%%%%
/pnPat
{penPattern FillQDPatDict}
def
%%%%%%%%%%%%%
% Name: fillPat [000A]
% Syntax: qdpat 0 fillPat -
% About: Stores the pattern info in the fillPattern dict.
%%%%%%%%%%%%%
/fillPat
{fillPattern FillQDPatDict}
def
%%%%%%%%%%%%%
% Name: bkPixPat [0012]
% Syntax: pict2pat bkPixPat -
% About: Stores the pattern info in the backPattern dict.
%%%%%%%%%%%%%
/bkPixPat
{backPattern FillQDPatDict}
def
%%%%%%%%%%%%%
% Name: pnPixPat [0013]
% Syntax: pict2pat pnPixPat -
% About: Stores the pattern info in the penPattern dict.
%%%%%%%%%%%%%
/pnPixPat
{penPattern FillQDPatDict}
def
%%%%%%%%%%%%%
% Name: fillPixPat [0014]
% Syntax: pict2pat fillPixPat -
% About: Stores the pattern info in the fillPattern dict.
%%%%%%%%%%%%%
/fillPixPat
{fillPattern FillQDPatDict}
def
%END Patterns